package com.example.yadmin.sys.service.impl;

import com.example.yadmin.sys.entity.Cart;
import com.example.yadmin.sys.entity.User;
import com.example.yadmin.sys.mapper.CartMapper;
import com.example.yadmin.sys.service.ICartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ag
 * @since 2023-10-15
 */
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements ICartService {

    @Override
    public void addCart(Cart cart) {
        this.baseMapper.insert(cart);
    }

    @Override
    public void deleteCartById(Integer id) {
        this.baseMapper.deleteById(id);
    }

    @Override
    public List<User> getUserMoneyByUsername(String username) {
        List<User> userList = this.baseMapper.getUserMoneyByUsername(username);
        return userList;
    }

    @Override
    public void updateCart(Cart cart) {
        this.baseMapper.updateById(cart);
    }

    @Override
    public Cart getCartById(Integer id) {
        Cart cart = this.baseMapper.selectById(id);
        return cart;
    }

}
